package com.qy137.service.impl;

import com.qy137.dao.MemberDao;
import com.qy137.entity.Member;
import com.qy137.service.MemberService;

import com.qy137.utils.CommonResult;
import com.qy137.vo.MemberVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
public class MemberServiceImpl implements MemberService {

    @Resource
    private MemberDao memberDao;


    @Override
    public CommonResult queryMemberTypeBang(Member member) {
        List<MemberVo> memberVos = memberDao.queryMemberTypeBang(member);
        List<Map> collect = memberVos.stream().map(item -> {
            HashMap<String, Object> map = new HashMap<>();
            map.put("name", item.getName() ? "会员" : "讲师");
            map.put("value", item.getValue());
            return map;
        }).collect(Collectors.toList());
        return new CommonResult(2000,"查询成功",collect);
    }
}
